namespace VfQuestionsMy
{
    using System;
    using System.Linq;
    using Rsdn.Janus;
    using Rsdn.Janus.CoreServices.Extensibility;
    using Rsdn.Janus.CoreServices.ObjectModel;
    using Rsdn.Janus.DataModel;
    using Rsdn.SmartApp;

    public class QuestionsMyMessage : VirtualForumMessage
    {
        public QuestionsMyMessage(IServiceProvider provider)
            : base(provider)
        {
        }

        /// <summary>
        /// Fills the children.
        /// </summary>
        protected override void FillChildren()
        {
            // do nothing    
        }

        /// <summary>
        /// Gets the messages.
        /// </summary>
        /// <param name="db">The db.</param>
        /// <returns></returns>
        protected override IQueryable<IForumMessage> GetMessages(IJanusDataContext db)
        {
            // don't move to class member we need actual value
            int selfId = SharedInfo.GetIntValue(SharedInfoKeys.SelfId) ?? 0;

            return db.Messages(m => m.UserID == selfId && m.ParentID <= 0);
        }

        protected override bool IsLoadAllMessages
        {
            get { return true; }
        }
    }
}